class monster extends EventDispatcher{
    attack: any;
    description:string="";
    hp: any;
    level: any;
    avatarx=0;
    avatary=0;
    x = 0;
    y = 0;
    id = 0;
    mapID = 0;
    name = ""; 
    monsterImage=new Image();
    monsterAvatarImage=new Image();

    view = new renderer.Bitmap(0, 0, this.monsterImage);
    parseFromConfig(config: any) {
        this.x = config.x;
        this.y = config.y;
        this.mapID= config.mapId;
        this.monsterImage.src= config.image;
        // this.monsterAvatarImage.src=config.avatar;
        this.id = config.id;
        this.attack = config.attack;
        this.name = config.name;
        // this.avatarx=config.avatarX;
        // this.avatary=config.avatarY;
        // this.description=config.description;
        // this.view.scaleX=this.view.scaleY=0.5;
        this.level=config.level;
        this.hp=config.hp;

     
      
    }
    get levell(){
        return this.level;

    }

    set levell(value: number) {
        this.level = value;
        this.dispatchEvent("userchange", "111");
    }
    toString() {
        return `[monster: name:${this.name} attack:${this.attack} monster: level:${this.level} ]`
    }
}









class MonsterManager extends EventDispatcher{
   Monsters: monster[] = [];
    constructor() {
        super();
    }
    parseFromConfig(config: any) {
        for (let item of config.monster) {
            const monster1 = new monster();
        
     
            monster1.parseFromConfig(item);
            monsterManager.Monsters.push(monster1);
           
           
           
        }
    }
}
    const monsterManager = new MonsterManager();

    













